home *** CD-ROM | disk | FTP | other *** search
- #include "MST_Defines.h"
- #include "MST_Externs.h"
- #include "MST_Prototypes.h"
-
-
- /*_____________________________________________________________________________
- Close_Elements()- close our element window
- _____________________________________________________________________________*/
-
-
- void Close_Elements ()
- {
- /*
- • See comments for Close_AboutMST() in the file About.c
- */
- if (ElementsDlog==NIL) return;
- DisposDialog (ElementsDlog);
- ElementsDlog = NIL;
- }
-
-
- /*_____________________________________________________________________________
- Open_Elements()- create and display our element window
- _____________________________________________________________________________*/
-
-
- void Open_Elements (int thisElement)
- {
- GDHandle saveDevice;
- CGrafPtr saveCGrafPtr;
- Str255 thisString, thatString;
-
- if (thisElement<=0) return; /*Just in case an invalid element*/
- if (thisElement>Max_NumElements) return; /*snuck past us*/
- /*
- • First, we may already have an element window open. We could allow many
- • to be open at once, but our program allows only one at a time. One
- • possibility is to simply reset the title of any existing element
- • window to the new element, along with any other data associated with
- • that window (for instance, if we had a variety of data about the
- • element to display in the element window). Here, we simply choose to
- • destroy the old window and create a new one.
- */
-
- if (ElementsDlog!=NIL) { Close_Elements (); }
- /*
- • See comments for Open_AboutMST() in the file About.c.
- */
-
- ElementsDlog = GetNewDialog (ResID_Elements, NIL, (WindowPtr)-1);
- /*
- • Now we have a little more work to do. Unlike our Periodic Chart window,
- • our element window can have any one of many titles. So first we switch
- • to the proper port,
- */
- GetGWorld (&saveCGrafPtr,&saveDevice);
- SetGWorld ((CGrafPtr)ElementsDlog,saveDevice);
- /*
- • get the full name of the element, or generate the text equivalent of
- • its atomic number if there is no name,
- */
- if (thisElement>=1&&thisElement<=110) GetIndString (thisString,ChemNamesStr,thisElement);
- else if (thisElement>=111)
- {
- strcpy (&thisString,"Element ");
- NumToString (thisElement,&thatString);
- p2cstr (&thatString);
- strcat (&thisString,&thatString);
- c2pstr (&thisString);
- }
- /*
- • And set the window title to the name of the element.
- */
- SetWTitle (ElementsDlog,&thisString);
- /*
- • Finally, we make the window visible. We have deliberately set the dialog
- • template to be initially invisible, so that the process of inserting the
- • element name into the window title is not visible to the user.
- */
- ShowWindow (ElementsDlog);
- /*
- • Note that Listing2 in the original article had a call to
- • SelectWindow(ElementsDlog) at this point. While the call did
- • no harm, it was extraneous. Using -1 as the third parameter to
- • GetNewDialog() makes it the active (frontmost) window.
- */
- }
-
-
- /*_____________________________________________________________________________
- UpDate_Elements()- update our element window
- _____________________________________________________________________________*/
-
-
- void UpDate_Elements()
- {
- GDHandle saveDevice;
- CGrafPtr saveCGrafPtr;
- int loop1;
- /*
- • Generally, see the comments to the update routine for the Periodic Chart
- • window in the file Periodic.c. The element window update routine is the
- • simplest of all...we are just drawing a dotted rectangle.
- */
- if (ElementsDlog==NIL) return;
-
- GetGWorld (&saveCGrafPtr,&saveDevice);
- SetGWorld ((CGrafPtr)ElementsDlog,saveDevice);
-
- BeginUpdate (ElementsDlog);
-
- for (loop1=13;loop1<=ElementsDlog->portRect.right-13;loop1+=2)
- {
- MoveTo (loop1,ElementsDlog->portRect.top+13);
- Line (0,0);
-
- MoveTo (loop1,ElementsDlog->portRect.bottom-13);
- Line (0,0);
- }
- for (loop1=13;loop1<=ElementsDlog->portRect.bottom-13;loop1+=2)
- {
- MoveTo (ElementsDlog->portRect.left+13, loop1);
- Line (0,0);
-
- MoveTo (ElementsDlog->portRect.right-13, loop1);
- Line (0,0);
- }
- EndUpdate (ElementsDlog);
- SetGWorld (saveCGrafPtr,saveDevice);
- }
-
-
- /*_____________________________________________________________________________
- Do_Elements()- handle events directed to our element window
- _____________________________________________________________________________*/
-
-
- void Do_Elements (EventRecord *thisEvent)
- /*
- • This is just a stub of a function to demonstrate where
- • you could add code to handle mouseclicks, keydowns, or other
- • events directed to the element window.
- */
-
- {
- }
-
-